#define _CRT_SECURE_NO_WARNINGS
#include <iostream>
#include <vector>
#include <queue>

using namespace std;

const int MOD = 80112002, N = 5010;
queue <int> q;
vector <int> edges[N];
int f[N];
int in[N], out[N];

int n, m;
int main()
{
	cin >> n >> m;
	for (int i = 1; i <= m; i++)
	{
		int x, y; cin >> x >> y;
		edges[x].push_back(y);
		in[y]++;
		out[x]++;
	}
	for (int i = 1; i <= n; i++)
	{
		if (in[i] == 0)
		{
			q.push(i);
			f[i] = 1;
		}
	}
	while (q.size())
	{
		auto x = q.front(); q.pop();
		for (auto y : edges[x])
		{
			in[y]--;
			f[y] = (f[x] + f[y]) % MOD;
			if (in[y] == 0) q.push(y);
		}
	}
	int ret = 0;
	for (int i = 1; i <= n; i++)
	{
		if (out[i] == 0)
			ret = (ret + f[i]) % MOD;
	}
	cout << ret << endl;
	return 0;
}